<?php
if(!isset($MAIN)){
	include_once("includes/class.ibnfm.php");
	$MAIN = new MAIN();
}

switch(@$_REQUEST['cat']){
	default:
		
	break;
	case 'profile':
?>
<div id="menu_tools">
	<ul>
		<li><a href="javascript:toggleFrm('frm_user');" class="btn">Ändra ditt lösenord</a></li>
		<li><a href="javascript:toggleFrm('frm_profile');" class="btn">Ändra dina profiluppgifter</a></li>
	</ul>
</div>
<?php
	break;
		case 'users':
		case 'groups':
		case 'persons':
?>
<div id="menu_tools">
	<ul>
		<?php
		if($MAIN->currentUser['grouplevel']<70){
		?>
		<li><a href="?cat=users&amp;view=all" class="btn">Alla anvädare</a></li>
		<li><a href="?cat=users&amp;view=add&amp;id=0" class="btn">Skapa anvädare</a></li>
		<?php
		}
		?>
		<li><a href="?cat=persons&amp;view=all" class="btn">Alla medlemar/personer</a></li>
		<li><a href="?cat=persons&amp;view=add&amp;id=0" class="btn">Skapa medlem/person</a></li>
		<?php
		if($MAIN->currentUser['grouplevel']==0){
		?>
		<li><a href="?cat=groups&amp;view=all" class="btn">Alla grupper</a></li>
		<li><a href="?cat=groups&amp;view=add" class="btn">Skapa grupp</a></li>
		<?php
		}
		?>
	</ul>
</div>
<?php
	break;
	case 'associations':
	case 'memberof':
?>
<div id="menu_tools">
	<ul>
		<li><a href="?cat=associations&amp;view=all" class="btn">Alla föreningar</a></li>
		<li><a href="?cat=associations&amp;view=add&amp;id=0" class="btn">Skapa förening</a></li>
		<?php
		if($MAIN->currentUser['grouplevel']<10){
		?>
		<li><a href="?cat=memberof&amp;view=all" class="btn">Medlem av list</a></li>
		<?php
		}
		?>
	</ul>
</div>
<?php
	break;
	case 'circles':
?>
<div id="menu_tools">
	<ul>
		<li><a href="?cat=circles&amp;view=all" class="btn">Alla aktiviteter</a></li>
		<li><a href="?cat=circles&amp;view=add&amp;id=0" class="btn">Skapa aktivitet</a></li>		
	</ul>
</div>
<?php
	break;
	case 'registrations':		
?>
<div id="menu_tools">
	<ul>
		<li><a href="?cat=registrations&amp;view=all" class="btn">Alla föranmälningar</a></li>
		<li><a href="?cat=registrations&amp;view=add&amp;id=0" class="btn">Skapa föranmälning</a></li>		
	</ul>
	
</div>
<?php
if(isset($registration)&&$registration['id']!=0){
	if($registration['type']!='Kulturprogram'){
//isStudyPlan
?>
<div style="padding:30px;margin-top:20px;" class="menu_tools">
	<a href="#registration" style="color:#78A73F;">Till Föranmälan (steg 1)</a><br/>
	<a href="#frm_studyplan" style="<?php if($MAIN->registrations->isStudyPlan($registration['id'])){?>color:#78A73F;<?php }else{?>color:#F43F4E;<?php }?>">Till Studiecirkelplan (steg 2)</a>
</div>
<?php
	}
?>
<div style="padding:30px;margin-top:20px;" class="menu_tools">	
	<div id="att_list">
		<?php
		$files = $MAIN->attachments->getFiles($registration['id'],tblPrefix.'registrations');
		if(count($files)>0){
		?>
		<fieldset>
		<legend>Befintliga dokument</legend>
		<table cellpadding="0" cellspacing="0" class="cnt_table_list" style="width:100%; margin-top:0px;">
			<tr>
				<th><span>Typ</span></th><th><span>Titel</span></th><th><span>Administrera</span></th>
			</tr>
			<?php 				
			
			foreach($files as $f){				
			?>
			<tr>
				<td style="text-align:center;"><span>dokument</span></td>
				<td style="text-align:center;"><span><?php echo($f['note']);?></span></td>
				<td style="text-align:center;">
				<span>
				<a href="<?php echo($f['filename']);?>" target="_blank"><img src="images/btn_file_download.png" alt="Ladda ner" title="Ladda ner"/></a>
				<a href="javascript:void(0);" onclick="delFile(<?php echo($f['id'])?>);"><img src="images/btn_admin_del.png" alt="Ta bort" title="Ta bort"/></a>
				</span>
				</td>
			</tr>
			<?php }?>
		</table>
		</fieldset>
		<script type="text/javascript">
			var delFile = function(id){
				var msg ='Bekräfta borttagning';
				if(confirm(msg)){
					ajaxGet('attachments.php', 'del_doc='+id+'&txt_cat=<?php echo($registration['id']);?>');
				}
			}
		</script>
		<?php
		}
		?>
	</div>
	<div id="att_upload">
		<form name="frm_doc" id="frm_doc" method="post" action="attachments.php" enctype="multipart/form-data">
			<fieldset>
				<legend>Ladda upp dokument/bild</legend>
				<input type="hidden" name="txt_cat" id="txt_cat" value="<?php echo($registration['id']);?>"/>			
				<span>Titel</span><br/>
				<input class="required" style="border:1px solid #8B8B8B; width:200px; height:16px;" type="text" name="txt_title" id="txt_title" value=""/><br/>
				<span style="display:block;">Välj dokument</span>		
				<div id="cnt_upload" style="float:left;">				
				<input class="required" type="file" name="file_doc" id="file_doc" value=""/>
				</div><br/><br/>
				<input style="float:right;" type="submit" name="btn_upload" value="Ladda upp"/>
			</fieldset>
		</form>
	</div>
</div>
<?php
}
?>
<?php
	break;
}
?>